package com.lhj.bootdemo.designmode.single;

/**
 * @author lhj
 * @version 1.0
 * @date 2022/5/10 1:53 下午
 * @description: 单例模式测试类
 */

public class TestSingle {
    public static void main(String[] args) throws InterruptedException {
        Singleton instance = Singleton.INSTANCE;
        for (int i = 0; i < 200; i++) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    for (int j = 0; j < 10; j++) {

                        instance.add();
                    }
                }
            }).start();
        }
        Thread.sleep(3000);
        System.out.println("结果："+instance.getCount());

    }
}
